package org.jetlinks.pro.cassandra.metadata;

import lombok.Generated;
import org.hswebframework.ezorm.rdb.metadata.JdbcDataType;
import org.hswebframework.ezorm.rdb.metadata.dialect.DefaultDialect;
import org.jetlinks.pro.cassandra.metadata.types.CassandraBigIntType;
import org.jetlinks.pro.cassandra.metadata.types.CassandraDecimalType;
import org.jetlinks.pro.cassandra.metadata.types.CassandraTextType;
import org.jetlinks.pro.cassandra.metadata.types.CassandraTimestampType;

import java.sql.JDBCType;

public class CassandraDialect extends DefaultDialect {

    public CassandraDialect() {
        registerDataType("text", CassandraTextType.INSTANCE);
        registerDataType("decimal", CassandraDecimalType.INSTANCE);
        registerDataType("bigint", CassandraBigIntType.INSTANCE);
        registerDataType("double", JdbcDataType.of(JDBCType.DOUBLE, Double.class));
        registerDataType("timestamp", CassandraTimestampType.INSTANCE);

    }

    @Override
    @Generated
    public String getQuoteStart() {
        return "\"";
    }

    @Override
    @Generated
    public String getQuoteEnd() {
        return "\"";
    }

    @Override
    @Generated
    public boolean isColumnToUpperCase() {
        return false;
    }

    @Override
    @Generated
    public String getId() {
        return "cassandra";
    }

    @Override
    @Generated
    public String getName() {
        return "Apache Cassandra";
    }
}
